<template>
  <!-- 所属公交车辆 -->
  <div class="app-container">
    <el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="68px">
      <el-form-item label="所属线路" prop="busLineId">
        <el-select v-model="queryParams.busLineId" clearable placeholder="请选择所属线路">
          <el-option
            v-for="dict in busLineList"
            :key="dict.id"
            :label="dict.busLineName"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="车牌照号" prop="licensePlateNumber">
        <el-input
          v-model="queryParams.licensePlateNumber"
          placeholder="请输入车牌照号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="自编号" prop="selfNumber">
        <el-input
          v-model="queryParams.selfNumber"
          placeholder="请输入自编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['bhxq:busInfo:add']"
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
        >新增</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="busInfoList" @selection-change="handleSelectionChange">
      <el-table-column label="所属线路" align="center" prop="busLineName" />
      <el-table-column label="车牌照号" align="center" prop="licensePlateNumber" />
      <el-table-column label="自编号" align="center" prop="selfNumber" />
      <el-table-column label="公交车车辆用途" align="center" prop="vehicleUse">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.bhxq_bus_use_to" :value="scope.row.vehicleUse" />
        </template>
      </el-table-column>
      <el-table-column label="是否新能源车" align="center" prop="isNewEnergy">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.bhxq_common_on_off" :value="scope.row.isNewEnergy" />
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleexamine(scope.row)"
          >查询</el-button>
          <el-button
            v-hasPermi="['bhxq:busInfo:edit']"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            v-hasPermi="['bhxq:busInfo:remove']"
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改公交车基本信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="52%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="自编号" prop="selfNumber">
              <el-input v-model="form.selfNumber" :disabled="disabledon" placeholder="请输入自编号" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="当前车牌照号" prop="licensePlateNumber">
              <el-input v-model="form.licensePlateNumber" :disabled="disabledon" placeholder="请输入当前车牌照号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="车辆品牌" prop="vehicleBrand">
              <el-input v-model="form.vehicleBrand" :disabled="disabledon" placeholder="请输入当前车辆品牌" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所属线路" prop="busLineId">
              <el-select v-model="form.busLineId" :disabled="disabledon" clearable placeholder="请选择所属线路">
                <el-option
                  v-for="dict in busLineList"
                  :key="dict.id"
                  :label="dict.busLineName"
                  :value="dict.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="产权人" prop="propertyOwner">
              <el-input v-model="form.propertyOwner" :disabled="disabledon" placeholder="请输入产权人" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="无障碍公交" prop="accessibleBus">
              <el-select v-model="form.accessibleBus" :disabled="disabledon" placeholder="请选择无障碍类型">
                <el-option
                  v-for="dict in dict.type.bhxq_common_on_off"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="无障碍类型" prop="accessibilityType">
              <el-select v-model="form.accessibilityType" :disabled="disabledon" placeholder="请选择无障碍类型">
                <el-option
                  v-for="dict in dict.type.bhxq_bus_barrier_free_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="车辆用途" prop="vehicleUse">
              <el-select v-model="form.vehicleUse" :disabled="disabledon" placeholder="请选择车辆用途">
                <el-option
                  v-for="dict in dict.type.bhxq_bus_use_to"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="生产厂家" prop="manufacturer">
              <el-input v-model="form.manufacturer" :disabled="disabledon" placeholder="请输入生产厂家" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车辆产地" prop="vehicleOrigin">
              <el-input v-model="form.vehicleOrigin" :disabled="disabledon" placeholder="请输入车辆产地" />
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="车辆来源" prop="vehicleSource">
              <el-select v-model="form.vehicleSource" :disabled="disabledon" placeholder="请选择车辆来源">
                <el-option
                  v-for="dict in dict.type.bhxq_bus_source"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="来源单位" prop="sourceUnit">
              <el-input v-model="form.sourceUnit" :disabled="disabledon" placeholder="请输入来源单位" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否新能源车" prop="isNewEnergy">
              <el-select v-model="form.isNewEnergy" :disabled="disabledon" placeholder="请选择是否新能源车">
                <el-option
                  v-for="dict in dict.type.bhxq_common_on_off"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="购入批次" prop="purchaseBatch">
              <el-input v-model="form.purchaseBatch" :disabled="disabledon" placeholder="请输入购入批次" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="管辖单位" prop="jurisdictionUnit">
              <el-input v-model="form.jurisdictionUnit" :disabled="disabledon" placeholder="请输入管辖单位" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="牌照登记日期" prop="licenseRegistrationDate">
              <el-date-picker
                v-model="form.licenseRegistrationDate"
                :disabled="disabledon"
                clearable
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择牌照登记日期"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="车辆型号" prop="vehicleModel">
              <el-input v-model="form.vehicleModel" :disabled="disabledon" placeholder="请输入车辆型号" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车长类型" prop="busLengthType">
              <el-select v-model="form.busLengthType" :disabled="disabledon" placeholder="请选择车长类型">
                <el-option
                  v-for="dict in dict.type.bhxq_bus_length_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="发动机号" prop="engineNumber">
              <el-input v-model="form.engineNumber" :disabled="disabledon" placeholder="请输入发动机号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="发动机型号" prop="engineModel">
              <el-input v-model="form.engineModel" :disabled="disabledon" placeholder="请输入发动机型号" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车架号" prop="chassisNumber">
              <el-input v-model="form.chassisNumber" :disabled="disabledon" placeholder="请输入车架号" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="排放标准类型" prop="emissionStandardType">
              <el-select v-model="form.emissionStandardType" :disabled="disabledon" placeholder="请选择排放标准类型">
                <el-option
                  v-for="dict in dict.type.bhxq_bus_emission_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="排量" prop="displacement">
              <el-input v-model="form.displacement" :disabled="disabledon" placeholder="请输入排量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="整备质量" prop="curbWeight">
              <el-input v-model="form.curbWeight" :disabled="disabledon" placeholder="请输入整备质量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="总质量" prop="grossWeight">
              <el-input v-model="form.grossWeight" :disabled="disabledon" placeholder="请输入总质量" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="是否有空调" prop="hasAirConditioning">
              <el-select v-model="form.hasAirConditioning" :disabled="disabledon" placeholder="请选择是否有空调">
                <el-option
                  v-for="dict in dict.type.bhxq_common_on_off"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="核定载客量" prop="approvedPassengerCapacity">
              <!--              <el-input v-model="form.approvedPassengerCapacity" placeholder="请输入核定载客量" />-->
              <el-input-number v-model="form.approvedPassengerCapacity" :disabled="disabledon" :precision="0" :step="1" size="small" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="座位数" prop="numberOfSeats">
              <!--              <el-input v-model="form.numberOfSeats" placeholder="请输入座位数" />-->
              <el-input-number v-model="form.numberOfSeats" :disabled="disabledon" :precision="0" :step="1" size="small" style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="技术等级" prop="technicalGrade">
              <el-select v-model="form.technicalGrade" :disabled="disabledon" placeholder="请选择技术等级">
                <el-option
                  v-for="dict in dict.type.bhxq_bus_technology_level"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车辆检验日期" prop="vehicleInspectionDate">
              <el-date-picker
                v-model="form.vehicleInspectionDate"
                :disabled="disabledon"
                clearable
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择车辆检验日期"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="服务人员" prop="servicePersonnel">
              <el-input v-model="form.servicePersonnel" :disabled="disabledon" placeholder="请输入服务人员" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="驾驶员数" prop="numberOfDrivers">
              <!--              <el-input v-model="form.numberOfDrivers" placeholder="请输入驾驶员数" />-->
              <el-input-number v-model="form.numberOfDrivers" :disabled="disabledon" :precision="0" :step="1" size="small" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车长" prop="vehicleLength">
              <el-input v-model="form.vehicleLength" :disabled="disabledon" placeholder="请输入车长" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车宽" prop="vehicleWidth">
              <el-input v-model="form.vehicleWidth" :disabled="disabledon" placeholder="请输入车宽" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="车高" prop="vehicleHeight">
              <el-input v-model="form.vehicleHeight" :disabled="disabledon" placeholder="请输入车高" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="前轮距" prop="frontWheelDistance">
              <el-input v-model="form.frontWheelDistance" :disabled="disabledon" placeholder="请输入前轮距" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="后轮距" prop="rearWheelDistance">
              <el-input v-model="form.rearWheelDistance" :disabled="disabledon" placeholder="请输入后轮距" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="轮胎数" prop="numberOfTires">
              <!--              <el-input v-model="form.numberOfTires" placeholder="请输入轮胎数" />-->
              <el-input-number v-model="form.numberOfTires" :disabled="disabledon" :precision="0" :step="1" size="small" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="转向形式" prop="steeringForm">
              <el-input v-model="form.steeringForm" :disabled="disabledon" placeholder="请输入转向形式" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="轮胎规格" prop="tireSpecifications">
              <el-input v-model="form.tireSpecifications" :disabled="disabledon" placeholder="请输入轮胎规格" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="轴距" prop="wheelbase">
              <el-input v-model="form.wheelbase" :disabled="disabledon" placeholder="请输入轴距" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="轴数" prop="numberOfAxles">
              <el-select v-model="form.numberOfAxles" :disabled="disabledon" placeholder="请选择动力类型">
                <el-option
                  v-for="dict in dict.type.bhxq_axle_num"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="动力类型" prop="powerType">
              <el-select v-model="form.powerType" :disabled="disabledon" placeholder="请选择动力类型">
                <el-option
                  v-for="dict in dict.type.bhxq_bus_power_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="是否有GPS" prop="hasGps">
              <el-select v-model="form.hasGps" :disabled="disabledon" placeholder="请选择是否有GPS">
                <el-option
                  v-for="dict in dict.type.bhxq_common_on_off"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车辆状态" prop="vehicleStatus">
              <el-select v-model="form.vehicleStatus" :disabled="disabledon" placeholder="请选择车辆状态">
                <el-option
                  v-for="dict in dict.type.bhxq_car_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="燃料类型" prop="fuelType">
              <el-select v-model="form.fuelType" :disabled="disabledon" placeholder="请选择燃料类型">
                <el-option
                  v-for="dict in dict.type.bhxq_car_fuel_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="报废日期" prop="mandatoryScrappingDate">
              <el-date-picker
                v-model="form.mandatoryScrappingDate"
                :disabled="disabledon"
                clearable
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择报废日期"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8" />
          <el-col :span="8" />
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="disabledon == false" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
// import { listBusInfo, getBusInfo, delBusInfo, addBusInfo, updateBusInfo } from '@/api/bhxq/busInfo'
// import { listAllBusLine } from '@/api/bhxq/busLine'

import {
  addBusInfo,
  delBusInfo,
  getAccident,
  getBusInfo,
  listAllBusLine,
  listBusInfo,
  updateBusInfo
} from '@/api/informationReport'

export default {
  name: 'Index',
  dicts: ['bhxq_bus_power_type', 'bhxq_bus_brand', 'bhxq_bus_barrier_free_type', 'bhxq_bus_use_to', 'bhxq_bus_source', 'bhxq_common_on_off', 'bhxq_bus_length_type', 'bhxq_common_on_off', 'bhxq_axle_num', 'bhxq_common_on_off', 'bhxq_car_fuel_type', 'bhxq_bus_emission_type', 'bhxq_bus_technology_level', 'bhxq_car_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 公交车基本信息表格数据
      busInfoList: [{}],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        selfNumber: null,
        licensePlateNumber: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        propertyOwner: [
          { required: true, message: '产权人不能为空', trigger: 'blur' }
        ],
        accessibleBus: [
          { required: true, message: '无障碍公交不能为空', trigger: 'change' }
        ],
        selfNumber: [
          { required: true, message: '自编号不能为空', trigger: 'blur' }
        ],
        licensePlateNumber: [
          { required: true, message: '车牌照号不能为空', trigger: 'blur' }
        ],
        vehicleBrand: [
          { required: true, message: '车辆品牌不能为空', trigger: 'blur' }
        ],
        busLineId: [
          { required: true, message: '所属路线不能为空', trigger: 'change' }
        ]
        // vehicleCompany: [
        //   { required: true, message: '车辆公司不能为空', trigger: 'blur' }
        // ],
        // accessibleBus: [
        //   { required: true, message: '无障碍公交不能为空', trigger: 'change' }
        // ],
        // accessibilityType: [
        //   { required: true, message: '无障碍类型不能为空', trigger: 'change' }
        // ],
        // propertyOwner: [
        //   { required: true, message: '产权人不能为空', trigger: 'blur' }
        // ],
        // vehicleUse: [
        //   { required: true, message: '车辆用途不能为空', trigger: 'change' }
        // ],
        // manufacturer: [
        //   { required: true, message: '生产厂商不能为空', trigger: 'blur' }
        // ],
        // vehicleOrigin: [
        //   { required: true, message: '车辆产地不能为空', trigger: 'blur' }
        // ],
        // vehicleSource: [
        //   { required: true, message: '车辆来源不能为空', trigger: 'change' }
        // ],
        // sourceUnit: [
        //   { required: true, message: '来源单位不能为空', trigger: 'blur' }
        // ],
        // isNewEnergy: [
        //   { required: true, message: '是否新能源车不能为空', trigger: 'change' }
        // ],
        // purchaseBatch: [
        //   { required: true, message: '购入批次不能为空', trigger: 'blur' }
        // ],
        // jurisdictionUnit: [
        //   { required: true, message: '管辖单位不能为空', trigger: 'blur' }
        // ],
        // licenseRegistrationDate: [
        //   { required: true, message: '牌照登记日期不能为空', trigger: 'blur' }
        // ],
        // vehicleModel: [
        //   { required: true, message: '车型不能为空', trigger: 'change' }
        // ],
        // model: [
        //   { required: true, message: '型号不能为空', trigger: 'blur' }
        // ],
        // busLengthType: [
        //   { required: true, message: '车长类型不能为空', trigger: 'change' }
        // ],
        // engineNumber: [
        //   { required: true, message: '发动机号不能为空', trigger: 'blur' }
        // ],
        // engineModel: [
        //   { required: true, message: '发动机型号不能为空', trigger: 'blur' }
        // ],
        // chassisNumber: [
        //   { required: true, message: '车架号不能为空', trigger: 'blur' }
        // ],
        // emissionStandardType: [
        //   { required: true, message: '排放标准类型不能为空', trigger: 'change' }
        // ],
        // displacement: [
        //   { required: true, message: '排量不能为空', trigger: 'blur' }
        // ],
        // curbWeight: [
        //   { required: true, message: '整备质量不能为空', trigger: 'blur' }
        // ],
        // grossWeight: [
        //   { required: true, message: '总质量不能为空', trigger: 'blur' }
        // ],
        // hasAirConditioning: [
        //   { required: true, message: '是否有空调不能为空', trigger: 'change' }
        // ],
        // approvedPassengerCapacity: [
        //   { required: true, message: '核定载客量不能为空', trigger: 'blur' }
        // ],
        // numberOfSeats: [
        //   { required: true, message: '座位数不能为空', trigger: 'blur' }
        // ],
        // technicalGrade: [
        //   { required: true, message: '技术等级不能为空', trigger: 'change' }
        // ],
        // vehicleInspectionDate: [
        //   { required: true, message: '车辆检验日期不能为空', trigger: 'blur' }
        // ],
        // servicePersonnel: [
        //   { required: true, message: '服务人员不能为空', trigger: 'blur' }
        // ],
        // numberOfDrivers: [
        //   { required: true, message: '驾驶员数量不能为空', trigger: 'blur' }
        // ],
        // vehicleLength: [
        //   { required: true, message: '车长不能为空', trigger: 'blur' }
        // ],
        // vehicleWidth: [
        //   { required: true, message: '车宽不能为空', trigger: 'blur' }
        // ],
        // vehicleHeight: [
        //   { required: true, message: '车高不能为空', trigger: 'blur' }
        // ],
        // frontWheelDistance: [
        //   { required: true, message: '前轮距不能为空', trigger: 'blur' }
        // ],
        // rearWheelDistance: [
        //   { required: true, message: '后轮距不能为空', trigger: 'blur' }
        // ],
        // numberOfTires: [
        //   { required: true, message: '轮胎数量不能为空', trigger: 'blur' }
        // ],
        // steeringForm: [
        //   { required: true, message: '转向形式不能为空', trigger: 'blur' }
        // ],
        // tireSpecifications: [
        //   { required: true, message: '轮胎规格不能为空', trigger: 'blur' }
        // ],
        // wheelbase: [
        //   { required: true, message: '轴距不能为空', trigger: 'blur' }
        // ],
        // numberOfAxles: [
        //   { required: true, message: '轴数不能为空', trigger: 'change' }
        // ],
        // powerType: [
        //   { required: true, message: '动力类型不能为空', trigger: 'change' }
        // ],
        // hasGps: [
        //   { required: true, message: '是否有GPS不能为空', trigger: 'change' }
        // ],
        // vehicleStatus: [
        //   { required: true, message: '车辆状态不能为空', trigger: 'change' }
        // ],
        // fuelType: [
        //   { required: true, message: '燃料类型不能为空', trigger: 'change' }
        // ],
        // mandatoryScrappingDate: [
        //   { required: true, message: '报废日期不能为空', trigger: 'blur' }
        // ]
      },
      busLineList: [],
      disabledon: true
    }
  },
  created() {
    this.getListAllBusLine()
    this.getList()
  },
  methods: {
    /** 查询公交车基本信息列表 */
    getList() {
      this.loading = true
      listBusInfo(this.queryParams).then(response => {
        this.busInfoList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        selfNumber: null,
        licensePlateNumber: null,
        vehicleBrand: null,
        vehicleCompany: null,
        accessibleBus: null,
        accessibilityType: null,
        propertyOwner: null,
        vehicleUse: null,
        manufacturer: null,
        vehicleOrigin: null,
        vehicleSource: null,
        sourceUnit: null,
        isNewEnergy: null,
        purchaseBatch: null,
        jurisdictionUnit: null,
        licenseRegistrationDate: null,
        vehicleModel: null,
        model: null,
        busLengthType: null,
        engineNumber: null,
        engineModel: null,
        chassisNumber: null,
        emissionStandardType: null,
        displacement: null,
        curbWeight: null,
        grossWeight: null,
        hasAirConditioning: null,
        approvedPassengerCapacity: null,
        numberOfSeats: null,
        technicalGrade: null,
        vehicleInspectionDate: null,
        servicePersonnel: null,
        numberOfDrivers: null,
        vehicleLength: null,
        vehicleWidth: null,
        vehicleHeight: null,
        frontWheelDistance: null,
        rearWheelDistance: null,
        numberOfTires: null,
        steeringForm: null,
        tireSpecifications: null,
        wheelbase: null,
        numberOfAxles: null,
        powerType: null,
        hasGps: null,
        vehicleStatus: null,
        fuelType: null,
        mandatoryScrappingDate: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: null
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.disabledon = false
      this.open = true
      this.title = '新增所属公交车辆'
    },
    /** 查看按钮操作 */
    handleexamine(row) {
      this.reset()
      const id = row.id || this.ids
      getBusInfo(id).then(response => {
        this.form = response.data
        if (this.form.isNewEnergy !== null) {
          this.form.isNewEnergy = Number(response.data.isNewEnergy)
        }
        if (this.form.hasGps !== null) {
          this.form.hasGps = Number(response.data.hasGps)
        }
        this.disabledon = true
        this.open = true
        this.title = '查看所属公交车辆'
      })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      console.log('form', this.form)
      const id = row.id || this.ids
      getBusInfo(id).then(response => {
        this.form = response.data
        if (this.form.isNewEnergy !== null) {
          this.form.isNewEnergy = Number(response.data.isNewEnergy)
        }
        if (this.form.hasGps !== null) {
          this.form.hasGps = Number(response.data.hasGps)
        }
        console.log('response.data.hasGps', response.data.hasGps)
        this.disabledon = false
        this.open = true
        this.title = '修改所属公交车辆'
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateBusInfo(this.form).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.open = false
              this.getList()
            })
          } else {
            addBusInfo(this.form).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除所属线路为"' + row.busLineName + '"的数据项？').then(function() {
        return delBusInfo(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('bhxq/busInfo/export', {
        ...this.queryParams
      }, `busInfo_${new Date().getTime()}.xlsx`)
    },
    /** 查询公交站点列表 */
    getListAllBusLine() {
      this.loading = true
      listAllBusLine().then(response => {
        this.busLineList = response.data
      })
    }
  }
}
</script>
